﻿using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using ATSBLL;
using ATSModel;
using System.Collections.Generic; 

/// <summary>
///ServiceForPackage 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class ServiceForPackage : System.Web.Services.WebService
{
    public TPackage tPackage;
    public TProductType productType; 
    public TRelevance tRelevance;
    public TPackConfig tPackConfig;
    public ServiceForPackage()
    {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
        tPackConfig = new TPackConfig();
    }
  
    [WebMethod(Description = "上传包装信息")]
    public bool UploalPackageData(TPackageInfo tp) //
    {

        tPackage = new TPackage();
        if (tp == null)
        {
            return false;
        }
                                                                                                                
        if (tPackage.UploalPackageData(tp))
        {
            return true;
        }
        return false;
    }


    [WebMethod(Description = "上传关联记录")]
    public bool UploalRelevanceData(TRelevanceInfo tr) 
    { 
        tRelevance = new TRelevance();
        if (tr == null)
        {
            return false;
        }
        if (tRelevance.UploalRelevanceData(tr))
        {
            return true;
        }
        return false;
    }

    [WebMethod(Description = "返回产品类型记录集合")]
    public List<TProductTypeInfo> ProductTypeList()
    {
        productType = new TProductType();
        return (List<TProductTypeInfo>)productType.LoadEntities();
    }

    [WebMethod(Description = "追溯条码是否存在")]
    public bool IsRASN(string retrospectSN)
    {
        tPackage = new TPackage(); 
        if (tPackage.IsRASN(retrospectSN))
        {
            return true;
        }
        return false;
    }


    [WebMethod(Description = "天线条码是否存在")]
    public bool IsASN(string antennaSN)
    {
        tPackage = new TPackage();
        if (tPackage.IsASN(antennaSN))
        {
            return true;
        }
        return false;
    }

    [WebMethod(Description = "条码是否已关联")]
    public bool IsRelevance(string SN)
    {
        tRelevance = new TRelevance();
        if (tRelevance.IsRelevance(SN))
        {
            return true;
        }
        return false;
    }

    [WebMethod(Description = "根据S代码返回包装配置信息")]
    public List<TPackConfigInfo> GetTPackConfigInfo_byTPID(string productTypeID)
    {
        return (List<TPackConfigInfo>)tPackConfig.TPackConfig_GetbyPID(productTypeID);
    }

}

